package org.stwy.pro.asset;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.apache.commons.lang.StringUtils;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.stwy.comm.base.BaseRecordsEntity;
import org.stwy.pro.property.PropertyEntity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.rap.common.annotation.MetaData;

/**
*版权信息 (c) RAP 保留所有权利.
*@author Rap.Codegen
*@Team RAP Team
*@Date 2015-4-4 17:05:42
*<p></p>
*
*@参与人：Rap.Codegen
*/
 
@MetaData(value = "资产")
@Entity
@Table(name = "stwy_asset")
@DynamicInsert
@DynamicUpdate
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class AssetEntity extends BaseRecordsEntity {
	private static final long serialVersionUID = 1L;
	
	public static final String ASSET_STATUS_NULL = "0";
	
	public static final String ASSET_STATUS_RENT = "1";
	
	public static final String ASSET_STATUS_SELF = "2";
	
	public static final String ASSET_STATUS_CANNOTRENT = "3";
	
	@MetaData(value = "所属物业")
	@ManyToOne(optional = false)
	@JoinColumn(name = "propertyId")
	private PropertyEntity property = new PropertyEntity();
	
	@MetaData(value = "资产名称",comments="")
	@Column(nullable = false,length = 100)
	private String theName;
	
	@MetaData(value = "资产状态",comments="",enumType="stwy_assetStatus")
	@Column(nullable = false,length = 4)
	private String assetState = ASSET_STATUS_NULL;
	
	@MetaData(value = "资产面积",comments="")
	@Column(nullable = true,length = 20)
	private Double area;
	
	@MetaData(value = "区域",comments="",enumType="stwy_region")
	@Column(nullable = true,length = 4)
	private String region;
	
	@MetaData(value = "用途",comments="",enumType="stwy_userfor")
	@Column(nullable = true,length = 4)
	private String usefor;
	
	@MetaData(value = "一级组别",comments="",enumType="stwy_groupOne")
	@Column(nullable = true,length = 4)
	private String groupOne;
	
	@MetaData(value = "二级组别",comments="",enumType="stwy_groupTwo")
	@Column(nullable = true,length = 4)
	private String groupTwo;
	
	@MetaData(value = "位置",comments="")
	@Column(nullable = true,length = 200)
	private String address;
	
	@MetaData(value = "房产证",comments="")
	@Column(nullable = true,length = 100)
	private String houseCert;
	
	@MetaData(value = "备注",comments="" )
	@Column(nullable = true,length = 2000)
	private String remark;
	
/*	@MetaData(value = "资产变更前状态",comments="",enumType="stwy_assetStatus")
	@Column(nullable = true,length = 4)
	private String stateBefore ;*/
	
	//@MetaData(value = "变更日期",comments="")
	@Column(nullable = true,length = 4)
	private Date recordDate ;
	
	//@MetaData(value = "变更原因",comments="")
	@Column(nullable = true,length = 500)
	private String reason;
	
	@MetaData(value = "不可出租类型",comments="",enumType="stwy_canNotRentType")
	@Column(nullable = true,length = 4)
	private String canNotRentType ;
	
	@MetaData(value = "产权情况",comments="",enumType="stwy_bookType")
	private String bookType;
	
	private Integer fileCount=0;

	public PropertyEntity getProperty() {
		return property;
	}

	public void setProperty(PropertyEntity property) {
		this.property = property;
	}

	public String getTheName() {
		return theName;
	}

	public void setTheName(String theName) {
		this.theName = theName;
	}

	public String getAssetState() {
		return assetState;
	}

	public void setAssetState(String assetState) {
		this.assetState = assetState;
	}

	public Double getArea() {
		return area;
	}

	public void setArea(Double area) {
		this.area = area;
	}

	public String getRegion() {
		return region;
	}

	public void setRegion(String region) {
		this.region = region;
	}

	public String getUsefor() {
		return usefor;
	}

	public void setUsefor(String usefor) {
		this.usefor = usefor;
	}

	public String getGroupOne() {
		return groupOne;
	}

	public void setGroupOne(String groupOne) {
		this.groupOne = groupOne;
	}

	public String getGroupTwo() {
		return groupTwo;
	}

	public void setGroupTwo(String groupTwo) {
		this.groupTwo = groupTwo;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getHouseCert() {
		return houseCert;
	}

	public void setHouseCert(String houseCert) {
		this.houseCert = houseCert;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
	
	
	
/*	public String getStateBefore() {
		return stateBefore;
	}

	public void setStateBefore(String stateBefore) {
		this.stateBefore = stateBefore;
	}
*/
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
	public Date getRecordDate() {
		return recordDate;
	}

	public void setRecordDate(Date recordDate) {
		this.recordDate = recordDate;
	}

	public String getReason() {
		return reason;
	}

	public void setReason(String reason) {
		this.reason = reason;
	}

	public String getCanNotRentType() {
		return canNotRentType;
	}

	public void setCanNotRentType(String canNotRentType) {
		this.canNotRentType = canNotRentType;
	}
	@Override
	public void prePersist() {
		if(StringUtils.isBlank(this.assetState)){
			setAssetState(ASSET_STATUS_NULL);
		}
		super.prePersist();
	}
	@Override
	public String toString() {
		return this.getTheName();
	}

	public String getBookType() {
		return bookType;
	}

	public void setBookType(String bookType) {
		this.bookType = bookType;
	}

	public Integer getFileCount() {
		return fileCount;
	}

	public void setFileCount(Integer fileCount) {
		this.fileCount = fileCount;
	}
	
}
